using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>
    public class EmployeeControl
    {
        #region Local Variable
        private EmployeeDataAccess _EmployeeDAO;
        #endregion Local Variable

        #region Method
        public EmployeeControl()
        {
            _EmployeeDAO = new EmployeeDataAccess();
        }

        public EmployeeInfo Get_Employee(
            String EmployeeCode
        , ref string sErr)
        {
            return _EmployeeDAO.Get_Employee(
            EmployeeCode
            , ref sErr);
        }

        public DataTable GetAll_Employee(ref string sErr)
        {
            return _EmployeeDAO.GetAll_Employee(ref sErr);
        }

        public Int32 Add_Employee(EmployeeInfo obj, ref string sErr)
        {
            return _EmployeeDAO.Add_Employee(obj, ref sErr);
        }

        public string Update_Employee(EmployeeInfo obj)
        {
            return _EmployeeDAO.Update_Employee(obj);
        }

        public string Delete_Employee(
            String EmployeeCode
        )
        {
            return _EmployeeDAO.Delete_Employee(
            EmployeeCode
            );
        }
        public Boolean IsExist_Employee(
            String EmployeeCode
        )
        {
            return _EmployeeDAO.IsExist_Employee(
            EmployeeCode
            );
        }

        /*  public string Delete_Employee(String arrID)
          {
              string kq = "";
              string[] arrStrID = arrID.Split(',');
              foreach (string strID in arrStrID)
              {
                  if (strID != "")
                  {
                      int ID = Convert.ToInt32(strID);
                      kq += _EmployeeDAO.Delete_Employee(ID);
                  }
              }
              return kq;
          } */

        public DataTable Search(String columnName, String columnValue, String condition, ref String sErr)
        {
            return _EmployeeDAO.Search(columnName, columnValue, condition, ref  sErr);
        }

        #endregion Method


        public string Delete(string empCode = null)
        {
            return _EmployeeDAO.Delete_Employee(empCode);
        }

        public bool RollbackTransaction(ref string sErr)
        {
            return _EmployeeDAO.RollbackTransaction(ref sErr);
        }

        public bool CommitTransaction(ref string sErr)
        {
            return _EmployeeDAO.CommitTransaction(ref sErr);
        }

        public object BeginTransaction(ref string sErr)
        {
            return _EmployeeDAO.BeginTransaction(ref sErr);
        }
    }
}
